﻿using System;
using System.IO.IsolatedStorage;
using System.IO;

class IsolatedStorageDemo
{
    static void Main()
    {
        IsolatedStorageFile userStorage = IsolatedStorageFile.GetUserStoreForAssembly();
        using (userStorage)
        {
            IsolatedStorageFileStream stream =
                new IsolatedStorageFileStream("IsolatedStorage.txt", FileMode.OpenOrCreate, userStorage);
            using (stream)
            {
                TextReader reader = new StreamReader(stream);
                string fileContents = reader.ReadToEnd();
                Console.WriteLine("Last accessed: {0}", fileContents);
                string newFileContents = DateTime.Now.ToString();
                stream.SetLength(0);
                TextWriter writer = new StreamWriter(stream);
                using (writer)
                {
                    writer.Write(newFileContents);
                }
            }
        }
    }
}
